MAXREFDES82# Code Documentation  V01.00
Maxim Smart Force Sensor
 All Files Functions Variables Macros Groups Pages
MAXREFDES82.c
Go to the documentation of this file.
1 
59 /* Includes ------------------------------------------------------------------*/
60 #include "main.h"
61 #include "WM.h"
62 #include "stm32f429i_discovery_lcd.h"
63 /* Private typedef -----------------------------------------------------------*/
64 /* Private define ------------------------------------------------------------*/
65 /* Private macro -------------------------------------------------------------*/
66 /* Private variables ---------------------------------------------------------*/
67 uint8_t GUI_Initialized = 0;
68 USBD_HandleTypeDef USBD_Device;
69 
70 /* Private function prototypes -----------------------------------------------*/
71 static void SystemClock_Config(void);
72 static void BSP_Config(void);
73 
74 /* Private functions ---------------------------------------------------------*/
75 extern void MainTask(void);
76 
82 int main(void)
83 {
84  /* STM32F4xx HAL library initialization:
85  - Configure the Flash prefetch, instruction and Data caches
86  - Configure the Systick to generate an interrupt each 1 msec
87  - Set NVIC Group Priority to 4
88  - Global MSP (MCU Support Package) initialization
89  */
90  HAL_Init();
91 
92  /* Configure the system clock to 168 MHz */
93  SystemClock_Config();
94 
95  /* Initialize LCD and LEDs */
96  BSP_Config();
97  /*
98  char* test = (char*)0xD0000000;
99  int loop = 0;
100  for(loop = 0; loop<100;loop++)
101  {
102  *test = loop;
103  *(test+1) = loop+1;
104  *(test+0x7ffff0) = loop+3;
105  }
106  */
107 
108  /* Init the STemWin GUI Library */
109  GUI_Init();
110  GUI_Initialized = 1;
111 
112  /* Init Device Library */
113  USBD_Init(&USBD_Device, &VCP_Desc, 0);
114 
115  /* Add Supported Class */
116  USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS);
117 
118  /* Add CDC Interface Class */
119  USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops);
120 
121  /* Start Device Process */
122  USBD_Start(&USBD_Device);
123 
124  MainTask();
125 
126  /* Run Application (Interrupt mode) */
127  while (1)
128  {
129  }
130 }
131 
137 static void BSP_Config(void)
138 {
139  /* Initialize STM32F429I-DISCO's LEDs */
140  BSP_LED_Init(LED3);
141  BSP_LED_Init(LED2);
142 
143  /* Initializes the SDRAM device */
144  BSP_SDRAM_Init();
145 
146 
147 
148  /* Initialize the Touch screen */
149  //BSP_TS_Init(240, 320);
150 
151 
152  /* Enable the CRC Module */
153  __HAL_RCC_CRC_CLK_ENABLE();
154 }
155 
176 static void SystemClock_Config(void)
177 {
178  RCC_OscInitTypeDef RCC_OscInitStruct;
179  RCC_ClkInitTypeDef RCC_ClkInitStruct;
180 
181  /* Enable Power Control clock */
182  __HAL_RCC_PWR_CLK_ENABLE();
183 
184  /* The voltage scaling allows optimizing the power consumption when the device is
185  clocked below the maximum system frequency, to update the voltage scaling value
186  regarding system frequency refer to product datasheet. */
187  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
188 
189  /* Configure RCC Oscillators: All parameters can be changed according to user’s needs */
190  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
191  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
192  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
193  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
194  //RCC_OscInitStruct.PLL.PLLM = 25;
195  //RCC_OscInitStruct.PLL.PLLN = 336;
196  RCC_OscInitStruct.PLL.PLLM = 15;
197  RCC_OscInitStruct.PLL.PLLN = 210;
198  RCC_OscInitStruct.PLL.PLLP = 2;
199  RCC_OscInitStruct.PLL.PLLQ = 7;
200  HAL_RCC_OscConfig (&RCC_OscInitStruct);
201 
202  /* RCC Clocks: All parameters can be changed according to user’s needs */
203  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_HCLK |RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
204  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
205  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
206  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
207  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
208  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
209 }
210 
211 
212 
213 #ifdef USE_FULL_ASSERT
214 
221 void assert_failed(uint8_t* file, uint32_t line)
222 {
223  /* User can add his own implementation to report the file name and line number,
224  ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
225 
226  /* Infinite loop */
227  while (1)
228  {
229  }
230 }
231 #endif
232 
233 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/